package com.zhihuichongcheng.application.ui.main.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.zhihuichongcheng.application.R;
import com.zhihuichongcheng.application.base.CustomWebviewActivity;
import com.zhihuichongcheng.application.bean.cricle.CricleBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 3water on 2016/10/24.
 */

public class CricleAdapter extends RecyclerView.Adapter<CricleAdapter.ViewHold> {
    private List<CricleBean> mListData = new ArrayList<>();
    private Context mContext;
    public CricleAdapter(Context context)
    {
        this.mContext = context;
    }

    @Override
    public ViewHold onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.listadapter_cricle,null);
        return new ViewHold(view);
    }

    @Override
    public void onBindViewHolder(ViewHold holder, int position) {
        holder.view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(mContext, CustomWebviewActivity.class);
                intent.putExtra("title","11111");
                intent.putExtra("url","http://www.baidu.com");
                mContext.startActivity(intent);
            }
        });
    }

    @Override
    public int getItemCount() {
        return mListData.size();
    }

    public void setData(List<CricleBean> list) {
        this.mListData.addAll(list);
    }

    public void clearData() {
        mListData.clear();
    }

    class ViewHold extends RecyclerView.ViewHolder{
        private View view;
        private TextView mTvTitle;
        public ViewHold(View itemView) {
            super(itemView);
            view = itemView;
            mTvTitle = (TextView)itemView.findViewById(R.id.tv_title);

        }
    }
}
